<?php
namespace Dry\Base;

class Container {

    private $service = array();

    private $instance = array();

    private $parameter = array();

    public function set($name, $class)
    {
        $this->service[$name] = $class;
        return $this;
    }

    public function get($name, $container=false)
    {
        $class = $this->service[$name];
        if($container){
            return new $class($this);
        }
        return new $class();
    }

    public function setInstance($name, $instance)
    {
        $this->instance[$name] = $instance;
        return $this;
    }

    public function getInstance($name)
    {
        return $this->instance[$name];
    }

    public function setParameter($name, $value)
    {
        $this->parameter[$name] = $value;
        return $this;
    }

    public function getParameter($name)
    {
        return $this->parameter[$name];
    }

}
?>
